<br/>
<%
  if work_items
    work_items.each do |work_item|
%>
  <br/>
  <li work_item_<%=work_item.id%>><b><%=work_item.name%></b> ,
  <%if work_item.tasks.count!=0%>
  共有  <b>
  <%=work_item.count%>
  计划在<%=work_item.start_date%> ~ <%=work_item.end_date%> 完成
  <%= link_to_remote image_tag("blank.png",:title => "删除工作项",:class=>"delete_item"), :url=>{:controller=>'work_items',:action=>'destroy',:id=>"#{work_item.id}"}, :confirm => '您确认删除这个工作项吗?', :method => :delete %>
  <a href="#" onclick="Element.toggle('work_item_<%=work_item.id%>_list');return false"><%=image_tag("blank.png",:title => "查看概要",:class=>"about_item")%></a>
  </b>  个任务，已完成  <b><%=work_item.completed_count%></b>  个，占整个工作项的 <b><%=work_item.rate%></b> %
    <br/>
    <br/>
    <div id="work_item_<%=work_item.id%>_list">
      <ul id="work_item_<%=work_item.id%>_uncompleted_list" class="sortable">
        <%work_item.uncompleted_tasks.each do |task|%>
          <%=render :partial=>"work_items/task_item",:locals=>{:task=>task,:work_item=>work_item}%>
        <%end%>
      </ul>
      <ul id="work_item_<%=work_item.id%>_completed_list" class="sortable">
        <%work_item.completed_tasks.each do |task|%>
          <%=render :partial=>"work_items/task_item",:locals=>{:task=>task,:work_item=>work_item}%>
        <%end%>
      </ul>
      <br/>
      <br/>
      <%if work_item.type=="Custom_WorkItem"%>
        <div style="float:right">
          <a href="#" onclick="Element.toggle('add_task_by_<%=work_item.id%>');return false">
             <span>添加新任务</span>
          </a>
        </div>
      <%end%>
      <%=sortable_element "work_item_#{work_item.id}_uncompleted_list",:url=>{:controller=>'work_items',:action=>"sort_tasks",:id=>"#{work_item.id},uncompleted"}%>
      <%=sortable_element "work_item_#{work_item.id}_completed_list",:url=>{:controller=>'work_items',:action=>"sort_tasks",:id=>"#{work_item.id},completed"}%>
    </div>
  <%else%>
  尚没有任务
    <div id="work_item_<%=work_item.id%>_list">
      <ul id="work_item_<%=work_item.id%>_uncompleted_list" class="sortable">
      </ul>
      <ul id="work_item_<%=work_item.id%>_completed_list" class="sortable">
      </ul>
      <br/>
      <br/>
    </div>
    <%if work_item.type=="Custom_WorkItem"%>
      <div style="float:right">
        <a href="#" onclick="Element.toggle('add_task_by_<%=work_item.id%>');return false">
           <span>添加新任务</span>
        </a>
      </div>
    <%end%>
  <%end%>
  </li>
  <br/>
  
  <%=render :partial=>'work_items/new_task_form',:locals=>{:work_item=>work_item}%>
  <div id="work_item_<%=work_item.id%>_place" style="display:none"></div>
<%end%>
<%end%>